package HomeWork.Chapter03;

/**
 * Enjoy programming!!!
 * Time: 2021/11/4 -  19:54
 */
public class SummationWhile04 {
    public static void main(String[] args){
        int n = 1;//指循环次数，分母的阶乘的最后一项
        int factorial = 1;
        int sum1 = 1;//阶乘的值
        double sum = 0;
        while (n <= 20){
            while(factorial <= n){
                sum1 *= factorial;
                factorial++;
            }
            sum += 1.0 / sum1;
//            System.out.print(sum + " ");System.out.print(sum1 + " ");System.out.println(n);

            factorial = 1;
            sum1 = 1;
            n++;
        }
        System.out.println(sum);
    }
}
